#Construct the Agent Object. The agent object is extended by most 
#other objects in this simulation. They will inherit the folllowing 
#variables and methods listed in this file. 
setConstructorS3("RAgent", function() {
	extend(Object(), "RAgent",
		.li = list(),    #List to hold Various Agents 
		.liindex = 0,    #Integer to keep track of current loction in list 
		.geography = "", #Will be given a matrix of lat, long positions. 
		                 #  For an environment or cell it may be a closed 
						 #  boundary. For a individual it may be a position
		.dayspassed = 0, #Integer to track the days passed, May soon be removed.
		.updated = -1    #Varialbe that will be either -1 or 1. Used to keep 
						 #  track of whether an agent needs to be updated. Stops
						 #  cases where more than one daily operation can occur
		#Add other nessesary general variables here

						 )
})
#Send a message from this particular object to the desired to object. This
#method calls the recievers do function to imeadiatly handle the message
setMethodS3("send", "RAgent", function(this, mess, to) {
	to$do(mess, this);
})
#The general do function. This will should be overriden in the extending 
#Object by declaring another do function so that specific operations 
#unique to the extended object can be completed. If no do function is declared 
#then the messages will be handled here 
setMethodS3("do", "RAgent", function(this, mess, fro) {
	#Warn that no do function specified for the desired agent
	print("You may need to write a do function in the desired recieving object")
})

#Set the geography of the Agent, this should be a two column matrix with either 
#one row, two colums of longnitue, latitude positions to represent a point or 
#five rows, two columns of positions to represent a closed boundary 
setMethodS3("setgeo", "RAgent", function(this, g) {
	this$.geography = g;
})

#The following four functions return helpful data about the geography

setMethodS3("maxlat", "RAgent", function(this) {
	max(this$.geography[,2]); #Northern bound
})
setMethodS3("minlat", "RAgent", function(this) {
	min(this$.geography[,2]); #Southern bound
})
setMethodS3("maxlon", "RAgent", function(this) {
	max(this$.geography[,1]); #Eastern bound
})
setMethodS3("minlon", "RAgent", function(this) {
	min(this$.geography[,1]); #Western bound
})
setMethodS3("getlo", "RAgent", function(this) {
	this$.geography[,1]; #Longnitude of a particular position 
})
setMethodS3("getla", "RAgent", function(this) {
	this$.geography[,2]; #Latitude of a particular position
})
setMethodS3("totlength", "RAgent", function(this) {
    # The width of the boundary
	max(this$.geography[,1]) - min(this$.geography[,1]);
})
setMethodS3("totheight", "RAgent", function(this) {
    # The height of the boundary
	max(this$.geography[,2]) - min(this$.geography[,2]);
})

#Add more helper methods here
